#!/bin/bash
#

set -e
ADB=${ADB:-"adb"}

DEST="/data/local/tmp/atx-agent"

echo "Build binary for arm ..."

export GOOS=linux
export CGO_ENABLED=0

go generate
GOARCH=arm64 go build -tags vfs
md5sum atx-agent

$ADB push atx-agent $DEST
$ADB shell chmod 755 $DEST
$ADB shell $DEST server --stop
$ADB shell $DEST server -d "$@"

$ADB forward tcp:7912 tcp:7912
curl localhost:7912/wlan/ip
